;
;	Vivod dvuznachnogo shestnadcetirichnogo chisla
;	----------------------------------------------
; Vhodi: DL soderjit vivodimoe chislo
; Vizovi: Write_digit_hex
;
Write_byte_hex:
	push bx
	push cx
	mov bl,dl
	mov cl,4h
	shr bl,cl		;Sdvig vpravo na 4 razryda
	call Write_digit_hex	;Vivod starshey cifri
	mov bl,dl
	and bl,0fh		;Obnulyem starshiy polubait
	call Write_digit_hex	;Vivld mladshey cifri
	pop cx 
	pop bx
	ret
;
;	Vivod shestnadcetirichnoi cifri
;	-------------------------------
; Vhodi: BL soderjit shestnadcetirichnuy cifru
; Vizovi: Write_char
Write_digit_hex:
	push dx
	mov dl,bl
	cmp dl,09h		;Esli DL>9, to perehodim na .ja 
	ja .ja                  
	add dl,30h              ;Ot 0 do 9 + 30h
	jmp .jmp
.ja:	add dl,37h              ;Ot A do F + 37h
.jmp:	call Write_char 
	pop dx
	ret
;
;	Vivod simvola na ekran
;	----------------------
; Vhodi: DL soderjit kod simvola, vivodimiy na ekran
;
Write_char:
	push ax
	cmp dl,20h
	jae .jae
	mov dl,2Eh
.jae:	mov ax,0200h		;Funkciy vivoda simvola
	int 21h			;Vivod simvola na ekran
	pop ax
	ret
;
;	Vivod desytichnogo chisla
;	-------------------------
; Vhodi: DX soderjit vivodimoe chislo
; Vizovi: 
Write_word_dec:
	push ax
	push bx
	push dx
	push cx
	xor cx,cx		;Obnulyem CX
	mov ax,dx
	mov bx,0Ah	
.jnz:	mov dx,0h
	div bx
	push dx
	inc cx
	or ax,ax		;Esli AX!=0 perehod .jnz
	jnz .jnz
.loop:	pop dx
	add dx,30h
	call Write_char
	loop .loop
	pop cx
	pop dx
	pop bx
	pop ax
	ret 
;
;	Vivod shestnadcetirichnogo chisla is dvuh byte
;	-------------------------
; Vhodi: DX soderjit vivodimoe chislo
; Vizovi: 
Write_word_hex1:
	push ax
	push bx
	push dx
	push cx
	xor cx,cx		;Obnulyem CX
	mov ax,dx
	mov bx,10h	
.jnz:	mov dx,0h
	div bx
	push dx
	inc cx
	or ax,ax		;Esli AX!=0 perehod .jnz
	jnz .jnz
.loop:	pop dx
	cmp dx,09h		;Esli DL>9, to perehodim na .ja 
	ja .ja                  
	add dx,30h              ;Ot 0 do 9 + 30h
	jmp .jmp
.ja:	add dx,37h              ;Ot A do F + 37h
.jmp:	call Write_char 
	loop .loop
	pop cx
	pop dx
	pop bx
	pop ax
	ret 
;
;	Vivod shestnadcetirichnogo chisla is dvuh byte
;	-------------------------
; Vhodi: DX soderjit vivodimoe chislo
; Vizovi: Write_byte_hex
Write_word_hex:
	push bx
	push cx
	push dx
	mov bx,dx
	mov cl,8h
	shr dx,cl		;Sdvig vpravo na 8 razryda
	call Write_byte_hex	;Vivod starshego byta
	mov dx,bx
	call Write_byte_hex	;Vivod mladshego byta
	pop dx
	pop cx 
	pop bx
	ret